all: add calloptions and handlercontext#86
Merged
Conversation
zchee
approved these changes
May 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant updates to enhance call configuration flexibility and improve handler functionality in the conformance framework. The key changes include the introduction of a new
CallOptionsclass for managing call-specific options like timeouts and abort events, updates to handler methods to include aHandlerContextfor richer context management, and adjustments to client and server implementations to integrate these enhancements.Call Configuration Enhancements:
CallOptionsclass insrc/connect/call_options.pyto encapsulate per-call configuration, including timeout and abort event support. This provides a cleaner and more flexible way to manage call-specific options.Clientclass insrc/connect/client.pyto acceptCallOptionsin both_call_unaryand_call_streammethods, enabling the use of the new configuration options.Handler Context Integration:
HandlerContextto handler methods inconformance/gen/connectrpc/conformance/v1/conformancev1connect/service_connect.py, allowing access to additional context like remaining timeout.conformance/server.pyto utilizeHandlerContextfor calculating timeout values dynamically and to improve request handling. [1] [2] [3]Refactoring and Interceptor Updates:
InterceptorwithHandlerInterceptorinexamples/server.pyto align with the new handler context implementation, ensuring compatibility with the updated call flow.wrap_unarymethod inexamples/server.pyto passHandlerContextto the next function in the interceptor chain.Streamlining Call Usage:
StreamRequestusage inconformance/client_runner.pyto separateCallOptionsfrom the request object, improving readability and modularity. [1] [2] [3]These changes collectively enhance the flexibility, maintainability, and clarity of the conformance framework while introducing new capabilities for managing call-specific configurations.